$(function () {
    var id = $.util.getRequest('id');
    if (id) {
        var url = $.util.getRequestJson('/json/sysMessage.findById.json');
        $.util.get(url, {id: id}, function (data) {
            $('#publishNotice').form('load', data.data);
            if (data.data.attachments) {
                if ($.util.isString(data.data.attachments)) {
                    data.data.attachments = JSON.parse(data.data.attachments);
                }
                var attachments = $('#attachments').html('');
                for (var i = 0; i < data.data.attachments.length; i++) {
                    var file = data.data.attachments[i];
                    var el = $('<div style="padding-top: 5px;"><a target="_blank" href="' + $.util.getRootPath() + file.savePath + '">' + file.fullName + '</a></div>');
                    attachments.append(el);
                }
                if (data.data.groupDic) {
                    var dictKey = $.util.getRequest('dictKey');
                    $.util.get($.util.getRequestJson('/dict/findByGroupKey.json'), {groupKey: "messageType"}, function (dicJson) {
                        for (var i = 0; i < dicJson.rows.length; i++) {
                            if (dicJson.rows[i].dictKey == data.data.groupDic) {
                                $('#groupDic').text(dicJson.rows[i].dictText);
                            }
                        }
                    });
                }
            }
        });
    }
});
